
// 动态计算header高度
var window_heigth = function () {

    var val = window.innerWidth * 0.25;

    $("header").css({
        height: val / 0.9
    });

    $(".banner").css({
        height: val / 1.2
    });

    $("#bottom").css({
        height: window.innerWidth * 0.3
    });
}

var imgsrc = function (data, key) {

    for (var i = 0; i < data.length; i++) {
        var current = data[i]
        if (current[key].indexOf('http') > -1) {
            data[i]['Logo'] = current[key].replace(/[\r\n]/g, "").replace(/[ ]/g, "").replace('["', '').replace('"]', '');
        } else {
            data[i]['Logo'] = 'http://lepinapi.91qulepin.com' + current[key].replace(/[\r\n]/g, "").replace(/[ ]/g, "").replace('["', '').replace('"]', '');
        }
    }
}

$.get('http://lepinapi.91qulepin.com/AppView/Index', function (data) {
    console.log(data)

    imgsrc(data.starFirmList, 'Logo');
    imgsrc(data.retMoney, 'logo');
    imgsrc(data.jobInfoLsit, 'logo');
	
    var retMoney = [], jobInfoLsit = [];

    for (var i = 0; i < 6; i++) {
		if (data.retMoney[i]) {
			retMoney.push(data.retMoney[i]);
		}
    }
	
	console.log(retMoney)
	
    new Vue({
        el: 'main',
        data: {
            starFirmList: data.starFirmList,
            retMoney: retMoney,
            jobInfoLsit: data.jobInfoLsit
        },
        methods: {
            toinfo: function (item) {
                window.open('../info/index.html?key=' + item.id);
            }
        }
    });

});

$('nav ul li').each(function () {
    switch ($(this).attr('data-type')) {
        case 'search':
            $(this).click(function () {
                window.open('../search/index.html');
            });
            break;
        case 'r_job':
            $(this).click(function () {
                window.open('../r_job/index.html');
            });
            break;
        case 'info':
            $(this).click(function () {
                window.open('../news/index.html');
            });
            break;
        case 'my':
            $(this).click(function () {
                window.open('../my/index.html');
            });
            break;
        case 'home':
            $(this).click(function () {
                window.open('../main/index.html');
            });
            break;
    }
});

function search() {
    window.open('../search/index.html?key=' + $('#search_val').val());
}

window.onload = function () {
    window_heigth();
}